import request from '@/utils/request';
import { removeToken } from '@/utils/auth';

export function login(data) {
  return request({
    url: '/backend/user/login',
    method: 'post',
    data
  });
}

/******* 
 * @description: 查看举报列表
 * @return {*}
 */
export function getReportList(params) {
  return request({
    url: '/backend/user/reportList',
    method: 'get',
    params
  });
}

/******* 
 * @description: 查看数据集合
 * @return {*}
 */
export function getDataList(params) {
  return request({
    url: '/backend/user/collection',
    method: 'get',
    params
  });
}

/******* 
 * @description: 查看在线人数
 * @return {*}
 */
export function getOnline(params) {
  return request({
    url: '/backend/user/online',
    method: 'get',
    params
  });
}

/******* 
 * @description: 处理举报
 * @return {*}
 */
export function dealReport(data) {
  return request({
    url: '/backend/user/reportResult',
    method: 'post',
    data
  });
}

export function getInfo(token) {
  // 模拟用户数据
  return new Promise((res) => {
    res({
      code: 200,
      data: {
        roles: ['admin'],
        introduction: 'I am a super administrator',
        avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
        name: 'Super Admin'
      }
    })
  })
  // return request({
  //   url: '/vue-element-admin/user/info',
  //   method: 'get',
  //   params: { token }
  // });
}

export function logout(token) {
  // return request({
  //   url: '/vue-element-admin/user/logout',
  //   method: 'post',
  //   params: { token }
  // });

  return new Promise((res) => {
    // 清除本地coockie
    removeToken('Admin-Token')
    res({})
  })
}

/******* 
 * @description: 系统用户列表
 * @return {*}
 */
export function userList(data) {
  return request({
    url: 'api/common/getSystemAvatar',
    method: 'get',
    data
  });
}
